A content addressable memory (CAM) is a type of computer memory that allows for high speed searches of a specific data pattern within its memory cells, which are organized as an array having rows and columns. A different data pattern may be stored in each row of the CAM. Data to be checked can be supplied to an input of the CAM, and the CAM may then compare the input to each row of the CAM array. If the CAM determines that the input matches one or more rows, the CAM returns a signal indicating the row or rows that match.
A CAM may be used to determine whether a certain data pattern is in a stream of data, such as data read from a hard disk drive or data received via a network. This may be useful for virus detection, for example. For instance, the stream of data may be analyzed to determine if it includes any data patterns that match any of the entries in a list (dictionary) of known virus patterns. The rows of the CAM array may store the known patterns, and non-overlapping blocks of the stream of data could be serially provided to the CAM in a block-wise manner so that each block is compared with the known patterns in the rows of the CAM array. To accommodate multiple possible different positions of a known pattern in a block of data wider than the known pattern, a ternary CAM (TCAM) with a width corresponding to the data block width is utilized, and the known pattern is stored in multiple entries corresponding to the multiple possible different positions, with “don't care” bits filling the remaining bits of each entry. Upon detection of a pattern match, desired actions could be taken such as further analysis, repair, quarantine, or deletion of the data containing the virus.